# -*- coding: utf-8 -*-

from PyQt5.QtSql import QSqlDatabase


class Db():

    _db = None

    def __init__(self):
        self.dbModel = QSqlDatabase.addDatabase('QSQLITE')
        self.dbModel.setDatabaseName('./database.db')
        if not self.dbModel.open():
            return False

    def close(self):
        self.dbModel.close()

    @staticmethod
    def instance():
        if Db._db:
            return Db._db
        else:
            Db._db = Db()
            return Db._db

